package com.jvup.gameshow.model.viewModel.impl;

import android.widget.BaseAdapter;

import androidx.databinding.BaseObservable;
import androidx.lifecycle.MutableLiveData;

import com.jvup.gameshow.R;
import com.jvup.gameshow.databinding.LayoutHomeItemGiftBinding;
import com.jvup.gameshow.model.viewModel.IHomeViewModel;
import com.jvup.common.support.base.BaseViewModel;
import com.jvup.common.widget.adapter.auto.SummerBindAdapter;
import com.jvup.common.widget.adapter.auto.AutoVariable;
import com.jvup.common.widget.adapter.auto.annotation.AdapterEntityBind;

import java.util.ArrayList;

public abstract class HomeViewModel extends BaseViewModel<IHomeViewModel> implements IHomeViewModel {

    private final ArrayList<GiftItemViewModel> giftList = new ArrayList();
    private SummerBindAdapter<GiftItemViewModel> adapter = new SummerBindAdapter(giftList);
    {
        giftList.add(new GiftItemViewModel());
        giftList.add(new GiftItemViewModel());
        giftList.add(new GiftItemViewModel());
        giftList.add(new GiftItemViewModel());
    }

    public HomeViewModel() {
        put("adapter",adapter);
    }

    public MutableLiveData<BaseAdapter> getAdapter(){
        return get("adapter");
    }

    @AdapterEntityBind(viewRid = R.layout.layout_home_item_gift)
    public class GiftItemViewModel extends BaseObservable implements AutoVariable<LayoutHomeItemGiftBinding> {

        @Override
        public void bindVariable(LayoutHomeItemGiftBinding viewBind) {
            viewBind.setGiftItemViewModel(this);
        }

    }

} 
